#!/usr/bin/env python
from misc.utility.scons_hints import *

import platform_macos_builders

Import("env")

files = [
    "os_macos.mm",
    "godot_application.mm",
    "godot_application_delegate.mm",
    "crash_handler_macos.mm",
    "display_server_macos_base.mm",
    "display_server_embedded.mm",
    "display_server_macos.mm",
    "embedded_debugger.mm",
    "embedded_gl_manager.mm",
    "godot_button_view.mm",
    "godot_content_view.mm",
    "godot_core_cursor.mm",
    "godot_status_item.mm",
    "godot_window_delegate.mm",
    "godot_window.mm",
    "key_mapping_macos.mm",
    "godot_menu_delegate.mm",
    "godot_menu_item.mm",
    "godot_open_save_delegate.mm",
    "native_menu_macos.mm",
    "dir_access_macos.mm",
    "tts_macos.mm",
    "rendering_context_driver_vulkan_macos.mm",
    "gl_manager_macos_angle.mm",
    "gl_manager_macos_legacy.mm",
]

if env.editor_build:
    files += [
        "editor/embedded_game_view_plugin.mm",
        "editor/embedded_process_macos.mm",
    ]

if env["library_type"] == "executable":
    files += ["godot_main_macos.mm"]
else:
    files += ["libgodot_macos.mm"]

if env["library_type"] == "static_library":
    prog = env.add_library("#bin/godot", files)
elif env["library_type"] == "shared_library":
    prog = env.add_shared_library("#bin/godot", files)
else:
    prog = env.add_program("#bin/godot", files)

if env["debug_symbols"] and env["separate_debug_symbols"]:
    env.AddPostAction(prog, env.Run(platform_macos_builders.make_debug_macos))

if env["generate_bundle"]:
    env.AlwaysBuild(env.CommandNoCache("generate_bundle", prog, env.Run(platform_macos_builders.generate_bundle)))
